static GType extended_layout_type = 0;
if (G_UNLIKELY(!extended_layout_type))
- extended_layout_type =
- g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkExtendedLayout"),
- sizeof (GtkExtendedLayoutIface),
- NULL, 0, NULL, 0);
+ {
+ extended_layout_type =
+ g_type_register_static_simple (G_TYPE_INTERFACE, I_("GtkExtendedLayout"),
+ sizeof (GtkExtendedLayoutIface),
+ NULL, 0, NULL, 0);
+
+ g_type_interface_add_prerequisite (extended_layout_type, GTK_TYPE_WIDGET);
+ }
return extended_layout_type;
}
* @minimum_size: location for storing the minimum size, or %NULL
* @natural_size: location for storing the preferred size, or %NULL
*
- * Retreives an extended layout item's desired size.
+ * Retreives a widget's minimum and natural size and caches the values.
*
- * Since: 2.20
+ * <note><para>This api will consider any restrictions imposed by
+ * #GtkSizeGroup<!-- -->s or previous calls to gtk_widget_set_size_request().
+ * </para></note>
+ *
+ * Since: 3.0
*/
void
gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
GtkRequisition *minimum_size,
GtkRequisition *natural_size)
{
- GtkExtendedLayoutIface *iface;
-
g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
g_return_if_fail (NULL != minimum_size || NULL != natural_size);
- iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
- iface->get_desired_size (layout, minimum_size, natural_size);
+ _gtk_size_group_compute_desired_size (GTK_WIDGET (layout), minimum_size, natural_size);
}
/**
* @minimum_size: location for storing the minimum size, or %NULL
* @natural_size: location for storing the preferred size, or %NULL
*
- * Retreives an extended layout item's desired width if it would given
- * the size specified in @height.
+ * Retreives a widget's desired width if it would be given
+ * the specified @height.
*
- * Since: 2.20
+ * Since: 3.0
*/
void
gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
GtkExtendedLayoutIface *iface;
g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
- iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
-
- if (iface->get_width_for_height)
- iface->get_width_for_height (layout, height, minimum_width, natural_width);
- else
- {
- GtkRequisition minimum_size;
- GtkRequisition natural_size;
- iface->get_desired_size (layout, &minimum_size, &natural_size);
-
- if (minimum_width)
- *minimum_width = minimum_size.width;
- if (natural_width)
- *natural_width = natural_size.width;
- }
+ iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
+ iface->get_width_for_height (layout, height, minimum_width, natural_width);
}
/**
* @minimum_size: location for storing the minimum size, or %NULL
* @natural_size: location for storing the preferred size, or %NULL
*
- * Retreives an extended layout item's desired height if it would given
- * the size specified in @width.
+ * Retreives a widget's desired height if it would be given
+ * the specified @width.
*
- * Since: 2.20
+ * Since: 3.0
*/
void
gtk_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
GtkExtendedLayoutIface *iface;
g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
- iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
- if (iface->get_height_for_width)
- iface->get_height_for_width (layout, width, minimum_height, natural_height);
- else
- {
- GtkRequisition minimum_size;
- GtkRequisition natural_size;
-
- iface->get_desired_size (layout, &minimum_size, &natural_size);
-
- if (minimum_height)
- *minimum_height = minimum_size.height;
- if (natural_height)
- *natural_height = natural_size.height;
- }
+ iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
+ iface->get_height_for_width (layout, width, minimum_height, natural_height);
}
#define __GTK_EXTENDED_LAYOUT_C__
#if 0
TODO: integrate height-for-width with size-groups
#else
- gtk_widget_get_desired_size (GTK_WIDGET(layout),
- minimum_height ? &minimum_size : NULL,
- natural_height ? &natural_size : NULL);
+ gtk_extended_layout_get_desired_size (layout,
+ minimum_height ? &minimum_size : NULL,
+ natural_height ? &natural_size : NULL);
if (minimum_height)
*minimum_height = minimum_size.height;
#if 0
TODO: integrate width-for-height with size-groups
#else
- gtk_widget_get_desired_size (GTK_WIDGET(layout),
- minimum_width ? &minimum_size : NULL,
- natural_width ? &natural_size : NULL);
+ gtk_extended_layout_get_desired_size (layout,
+ minimum_width ? &minimum_size : NULL,
+ natural_width ? &natural_size : NULL);
if (minimum_width)
*minimum_width = minimum_size.width;
#endif
}
-/**
- * gtk_widget_get_desired_size:
- * @widget: a #GtkWidget
- * @minimum_size: location for storing the @widget's minimum size, or %NULL
- * @natural_size: location for storing the @widget's preferred size, or %NULL
- *
- * Retreives a widget's desired size, considering restrictions imposed by
- * #GtkSizeGroup<!-- -->s. See also: gtk_extended_layout_get_desired_size().
- *
- * Since: 2.20
- */
-void
-gtk_widget_get_desired_size (GtkWidget *widget,
- GtkRequisition *minimum_size,
- GtkRequisition *natural_size)
-{
- g_return_if_fail (GTK_IS_WIDGET (widget));
- _gtk_size_group_compute_desired_size (widget, minimum_size, natural_size);
-}
-
static void
gtk_widget_layout_interface_init (GtkExtendedLayoutIface *iface)
{